﻿using System.Threading.Tasks;
using EcoSystem.Permissions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace EcoSystem.ConfigCategorys;

/// <summary>
/// 配置分类管理
/// </summary>
[Area(EcoSystemRemoteServiceConsts.ModuleName)]
[RemoteService(Name = EcoSystemRemoteServiceConsts.RemoteServiceName)]
[Route("api/Platform/configCategory")]
public class ConfigCategoryController : EcoSystemController, IConfigCategoryAppService
{
    private readonly IConfigCategoryAppService _service;

    public ConfigCategoryController(IConfigCategoryAppService service)
    {
        _service = service;
    }

    /// <summary>
    /// 创建
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost]
    public async Task<ConfigCategoryDto> CreateAsync(CreateOrUpdateConfigCategoryDto input)
    {
        return await _service.CreateAsync(input);
    }

    /// <summary>
    /// 获取详情
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet]
    [Route("{id}")]
    public async Task<ConfigCategoryDto> GetAsync(string id)
    {
        return await _service.GetAsync(id);
    }

    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="id"></param>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPut]
    [Route("{id}")]
    public async Task<ConfigCategoryDto> UpdateAsync(string id, CreateOrUpdateConfigCategoryDto input)
    {
        return await _service.UpdateAsync(id, input);
    }


    /// <summary>
    /// 列表查询
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpGet]
    public async Task<PagedResultDto<ConfigCategoryDto>> GetListAsync(GetConfigCategoryInput input)
    {
        return await _service.GetListAsync(input);
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpDelete]
    [Route("{id}")]
    public async Task DeleteAsync(string id)
    {
        await _service.DeleteAsync(id);
    }

}
